package com.inlaylink.cordova.plugin.alipay;

import com.alipay.api.AlipayResponse;
import com.alipay.api.response.AlipayTradePrecreateResponse;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONStringer;

public class CustomAlipayTradePrecreateResponse extends AlipayTradePrecreateResponse implements IParseResponse {

	@Override
	public void parsedResponse(String json) throws JSONException {
		JSONObject obj =  new JSONObject(json).getJSONObject("alipay_trade_precreate_response");
		this.setCode(obj.getString("code"));
		this.setMsg(obj.getString("msg"));
		this.setOutTradeNo(obj.getString("out_trade_no"));
		this.setQrCode(obj.getString("qr_code"));
	}

	@Override
	public String parsedJson() throws JSONException {
		JSONStringer json = new JSONStringer();
		json.object();
		json.key("code").value(this.getCode());
		json.key("msg").value(this.getMsg());
		json.key("out_trade_no").value(this.getOutTradeNo());
		json.key("qr_code").value(this.getQrCode());
		json.endObject();
		return json.toString();

		
	}

}
